<?php
class Administrator_Model_Contact extends Administrator_Model_System{
	public function __construct() {
		$this->db = Zend_Registry::get ( 'vicdbsystem' );
		$this->lang = new Nguyen_language_system ();
	}
	public function insertContact($name,$diachi,$email,$website,$mobile,$phone,$fax,$image,$status){
		$data = array ('name' => $name, 'diachi' => $diachi,'email' => $email,'website' => $website,'mobile'=>$mobile,'phone' => $phone,'fax' => $fax, 'image' => $image,'status' => $status );
		$this->db->insert ( 'contact', $data );
		return $this->db->lastInsertId ();
	}
	public function updateContact($id, $name,$diachi,$email,$website,$mobile,$phone,$fax,$image) {
		$where = "id = '$id'";
		$data = array ('name' => $name, 'diachi' => $diachi,'email' => $email,'website' => $website,'mobile'=>$mobile,'phone' => $phone,'fax' => $fax, 'image' => $image);
		$this->db->update ( 'contact', $data, $where );
	}
	public function delContact($id) {
		$where = "id =  '$id'";
		$this->db->delete ( 'contact', $where );
	}
	
	public function GetAllContactInfo()
	{
		$sql = 'select * from contact';
		return $this->db->fetchAll($sql);
	}
	
	public function GetContactInfo($id){
		$sql = 'select * from contact where id = "'.$id.'"';
		return $this->db->fetchRow($sql);
	}
	public function deleteContact($id) {
		$info = $this->GetContactInfo($id);
		$this->DeleteImageOnHost('contact', $info['image']);
		$where = "id =  '$id'";
		$this->db->delete ( 'contact', $where );
	}
}
